import requests
class JianZhu():
    def __init__(self):
        # TODO 2025/11/18 修改请求地址 或者 请求参数
        self.url = "https://jzsc.mohurd.gov.cn/APi/webApi/dataservice/query/comp/list?pg={}&pgsz=15&total=450"
        # TODO 修改请求头
        self.headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
            'Referer': 'https://jzsc.mohurd.gov.cn/data/company',
            'V': '231012'
        }
        self.data = {}

    def get_Data(self, page):
        # TODO 按照实际请求发送
        res = requests.get(self.url.format(page), headers=self.headers)
        return res.text

    def parse_Data(self, data):
        # sekiro 中获取前端解析的数据
        data = {
            "group": "rpc-test",
            "action": "ths",
            'data': data
        }
        # time.sleep(3)
        res = requests.post(url="http://127.0.0.1:5612/business-demo/invoke", data=data, verify=False)
        print(res.json())
        if res.json().get('data'):
            print(res.json()['data'])
        else:
            print('连接问题')

    def main(self):
        for i in range(1, 30):
            data = self.get_Data(i)
            self.parse_Data(data)


if __name__ == '__main__':
    jz = JianZhu()
    jz.main()
